@echo off
echo Go Cross-Compilation Script
echo ===========================
echo.

:menu
echo Select target architecture:
echo 1. Linux x86_64 (amd64)
echo 2. Linux ARM64 (arm64)
echo 3. Linux ARM (arm)
echo 4. Windows x86_64 (amd64)
echo 5. Windows ARM64 (arm64)
echo 6. macOS x86_64 (amd64)
echo 7. macOS ARM64 (arm64)
echo 8. Build all Linux variants
echo 9. Exit
echo.
set /p choice="Enter your choice (1-9): "

if "%choice%"=="1" goto linux_amd64
if "%choice%"=="2" goto linux_arm64
if "%choice%"=="3" goto linux_arm
if "%choice%"=="4" goto windows_amd64
if "%choice%"=="5" goto windows_arm64
if "%choice%"=="6" goto darwin_amd64
if "%choice%"=="7" goto darwin_arm64
if "%choice%"=="8" goto build_all_linux
if "%choice%"=="9" goto exit
echo Invalid choice. Please try again.
echo.
goto menu

:linux_amd64
echo.
echo Building for Linux x86_64...
set GOOS=linux
set GOARCH=amd64
go build -o websocket-server-linux-amd64 .
goto check_result

:linux_arm64
echo.
echo Building for Linux ARM64...
set GOOS=linux
set GOARCH=arm64
go build -o websocket-server-linux-arm64 .
goto check_result

:linux_arm
echo.
echo Building for Linux ARM...
set GOOS=linux
set GOARCH=arm
go build -o websocket-server-linux-arm .
goto check_result

:windows_amd64
echo.
echo Building for Windows x86_64...
set GOOS=windows
set GOARCH=amd64
go build -o websocket-server-windows-amd64.exe .
goto check_result

:windows_arm64
echo.
echo Building for Windows ARM64...
set GOOS=windows
set GOARCH=arm64
go build -o websocket-server-windows-arm64.exe .
goto check_result

:darwin_amd64
echo.
echo Building for macOS x86_64...
set GOOS=darwin
set GOARCH=amd64
go build -o websocket-server-darwin-amd64 .
goto check_result

:darwin_arm64
echo.
echo Building for macOS ARM64...
set GOOS=darwin
set GOARCH=arm64
go build -o websocket-server-darwin-arm64 .
goto check_result

:build_all_linux
echo.
echo Building all Linux variants...
echo Building Linux x86_64...
set GOOS=linux
set GOARCH=amd64
go build -o websocket-server-linux-amd64 .
echo Building Linux ARM64...
set GOOS=linux
set GOARCH=arm64
go build -o websocket-server-linux-arm64 .
echo Building Linux ARM...
set GOOS=linux
set GOARCH=arm
go build -o websocket-server-linux-arm .
echo.
echo All Linux builds completed!
goto list_files

:check_result
if %errorlevel% equ 0 (
    echo Build successful!
) else (
    echo Build failed with error code %errorlevel%
)
echo.

:list_files
echo Current directory contents:
dir websocket-server* | findstr websocket-server
echo.
goto menu

:exit
echo Goodbye!
exit /b 0 